//
//  LogisticsStore.m
//  NewPro
//
//  Created by RYX on 2018/10/23.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "LogisticsStore.h"
#import "LogisticsModel.h"

@implementation LogisticsStore


- (void)getLogisticsInfoWithCom:(NSString *)com andNo:(NSString *)no andKey:(NSString *)key andPhone:(NSString *)phone Success:(void(^)(NSArray *listArr))success Failure:(void(^)(NSString *errorStr))failure{
    
    //http://www.kuaidi100.com/query?type=zhongtong&postid=75102616812902
    NSString *url = [NSString stringWithFormat:@"http://v.juhe.cn/exp/index"];

//    NSDictionary *dic = @{
//                          @"type":@"SF",
//                          @"postid":@"348148335994",
//                          };
    NSDictionary *dic = @{
                          @"com":com,
                          @"no":no,
                          @"receiverPhone":phone,
                          @"key":WuLiuAppKey
                          };

    [HttpTool getUrlWithString:url parameters:dic success:^(id responseObject) {
        
        if ([responseObject[@"resultcode"] integerValue] == 200) {

            NSArray *listArr = [LogisticsModel mj_objectArrayWithKeyValuesArray:responseObject[@"result"][@"list"]];
            NSArray *arr = [[listArr reverseObjectEnumerator] allObjects];
            success(arr);
        }else{

            failure(responseObject[@"reason"]);
        }
    } failure:^(NSError *error) {

        failure(@"查询失败");
    }];
}


@end
